﻿using Npgsql;
using NpgsqlTypes;
using PcaCore.BOL.Tablas;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using log4net;

namespace PcaCore.DAL.Tablas
{
    public class dTConfiguracion
    {
        private static readonly ILog log = LogManager.GetLogger(typeof(dTConfiguracion));

        private static oTConfiguracion Get(string configuracionId)
        {
            try
            {
                return Core.GetObjectDb<oTConfiguracion>("pca_tablas.fn_get_configuracion",
                                                         new oParametro(NpgsqlDbType.Text, configuracionId));
            }
            catch (Exception ex)
            {
                throw Core.LogException(log, ex, MethodBase.GetCurrentMethod().Name);
            }
        }
        
        #region Public

        public static string GetIdMonedaPordefecto()
        {
            return Get("MonedaDefault").valor;
        }

        public static List<oTConfiguracion> GetList()
        {
            try
            {
                return Core.GetListObjecstDb<oTConfiguracion>("pca_tablas.fn_get_list_configuraciones");
            }
            catch (Exception ex)
            {
                throw Core.LogException(log, ex, MethodBase.GetCurrentMethod().Name);
            }
        }

        #endregion
    }
}
